<template>
	<div class="pages">
		<img src="../../assets/images/bg.png" style="width: 100%;height:100vh;" />

		<div class="content">
			<div style="width: 80%;margin: auto;padding: 80px 0;">
				<baseBlock title="账号登录" row="heng" :Left='20' :bottom='40' :fontSize="28"></baseBlock>

				<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-position='top' label-width="100px"
					class="demo-ruleForm">
					<el-form-item label="UID" prop="name">
						<el-input v-model="ruleForm.name" placeholder="请输入您的UID"></el-input>
					</el-form-item>

					<el-form-item label="密码" prop="password">
						<el-input v-model="ruleForm.password" placeholder="请输入您的登录密码"></el-input>
					</el-form-item>


					<el-form-item prop="isRead">
						<el-checkbox v-model="ruleForm.isRead" name="type"></el-checkbox>
						<span class="u-margin-left-10">
							我已阅读并同意
							<span style="color: #1480F9;">《用户隐私协议及条款》</span>
						</span>
					</el-form-item>
				</el-form>

				<div style="width: 60%;margin:80px auto;">
					<el-button round type="primary" @click="submitForm('ruleForm')">立即登录
						<i class="el-icon-right u-margin-left-20"></i>
					</el-button>
				</div>

			</div>

		</div>
	</div>
</template>

<script>
	export default {
		data() {
			var checkRead = (rule, value, callback) => {
				if (!value) {
					return callback(new Error('请勾选阅读用户隐私协议'));
				} else {
					callback();
				}

			};
			return {


				ruleForm: {
					name: '',
					password: '',
					isRead: false
				},
				rules: {
					name: [{
							required: true,
							message: '请输入UID',
							trigger: 'blur'
						},

					],
					password: [{
							required: true,
							message: '请输入密码',
							trigger: 'blur'
						},
						{
							min: 3,
							message: '密码太短了',
							trigger: 'blur'
						}
					],
					isRead: [{
						validator: checkRead,
						trigger: 'blur'
					}]
				}
			}
		},
		methods: {
			submitForm(formName) {

				this.$refs[formName].validate((valid) => {
					if (valid) {
						this.$message.success({
							message: "登录成功",
							onClose: (res) => {
								this.$router.push({
									path: "/index"
								}, () => {
									location.reload()
								});
							}
						})
					} else {
						console.log('error submit!!');
						return false;
					}
				});
			},
			resetForm(formName) {
				this.$refs[formName].resetFields();
			}
		}
	}
</script>

<style scoped="scoped">
	.pages {
		overflow: hidden;
	}

	.el-input {
		width: 60%;

	}

	/deep/ .el-input__inner {
		background: #F8FAFF;
		border-radius: 20px;
		border: 0;
	}


	.el-button {
		width: 100%;
		padding: 20px 0;
		border-radius: 40px;

	}

	.content {
		width: 620px;
		height: 660px;
		background: rgba(255, 255, 255, 1);
		box-shadow: 8px 0px 20px rgba(147, 146, 146, 0.1);

		border-radius: 30px;
		position: fixed;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -50%);
	}
</style>
